<form name="form_admin" method="POST" action="<?php echo formEditAction()?>">
<input type="hidden" name="id" value="<?echo $id?>" />
<input type="hidden" name="opt" value="update" />
<table width="100%" style="padding-left:10px; line-height:2" cellpadding="0" cellspacing="0">
	
   <tr>
        <td><strong>Properties of <a href="?opt=edit&id=<?echo $id?>">
			<font color="#FF0000"><?echo $category['cName']?></font></a></strong></td>
      <td>	</td>
    </tr>
    <tr>
		<td height="10"></td>
	</tr>
	<tr>
		<td colspan="2">
			<table width="100%"  cellpadding="4" cellspacing="1" id="tblsort">
			<tr class="headtb" nodrop="true" nodrag="true">
				<td width="5%"><?echo _ORDER?></td>
				<td width="20%"><?echo _NAME?></td>
				<td width="20%"><?echo _DESCRIPTION?></td>
				<td >Select</td>

			</tr>
			</table>
		</td>
	</tr>
	<tr>
        <td>&nbsp;</td>
      <td>
			<input type="button" class="b1" value="<?echo _ADDROW?>" onclick="addfield()">
			<input type="button" class="b1" value="Del rows selected" onclick="delrows()">
			<input type="button" onclick="location.reload(true)" class="b1"  value="<?echo _RESET?>">
			</td>
    </tr>

</table>
</form>

<script type="text/javascript">
(new TableDnD).init("tblsort");
var orderrow=0;
var idmax = 1;
function addfield(id,vl1,vl2)
{
	if(id!=undefined)
	{
		idmax=id;
	}else
	{
		idmax++;
	}
	tblroot=getId("tblsort").tBodies[0];
	var newtr=document.createElement("tr");
	newtr.className='row_'+(orderrow%2);
	var newtd=document.createElement("td");
	var input1=document.createElement("input");
	input1.className="ordertext";
	//input1.setAttribute("type","hidden");
	input1.id="listorder_"+orderrow;
	input1.name="listorder[]";
	input1.value=orderrow+1;
	newtd.appendChild(input1);
	newtr.appendChild(newtd);

	newtd=document.createElement("td");
	input1=document.createElement("input");
	input1.className="namefproduct";
	input1.name="listfieldname[]";
	if(vl1!=undefined)input1.value=vl1;
	newtd.appendChild(input1);

	input1=document.createElement("input");
	input1.setAttribute("type","hidden");
	input1.value=idmax;
	input1.name="listid[]";

	newtd.appendChild(input1);
	newtr.appendChild(newtd);

	newtd=document.createElement("td");
	input1=document.createElement("input");
	input1.className="namefproduct";
	input1.name="listdescription[]";
	if(vl1!=undefined)input1.value=vl2;
	newtd.appendChild(input1);
	newtr.appendChild(newtd);

	newtd=document.createElement("td");
	newtd.innerHTML="<input type='checkbox' name='del_id"+orderrow+"' id='del_id"+orderrow+"' value=''/>";
	newtr.appendChild(newtd);

	tblroot.appendChild(newtr);
	orderrow++;
	(new TableDnD).init("tblsort");
}
function delrows()
{
	if(confirm('<?echo _DOYOUWANTDELETE?> ?')==false)return;
	tblroot=getId("tblsort").tBodies[0];
	for(i=0;i<orderrow;i++)
	{
		var cbsel=getId("del_id"+i);
		if(cbsel.checked)
		{
			tblroot.removeChild(cbsel.parentNode.parentNode);
		}
	}


}

<?
foreach($fields as $i=>$field)
{
?>
	addfield(<?echo $field[0]?>,"<?echo $field[1]?>","<?echo $field[2]?>");
<?
}
?>
</script>
